import {defHttp} from "/@/utils/http/axios";
import {ErrorMessageMode} from "/#/axios";
import {
    CertificateDto,
    CertificateListModel,
    CertificateQueryConditionDto
} from "/@/api/ehs/model/certificateInfoModel";

enum Api{
   CertificateQuery = '/ehs/certificate/query',
    CertificateAdd = '/ehs/certificate/add',
    CertificateUpdate = '/ehs/certificate/update',
    CertificateDelete = '/ehs/certificate/delete',
    CertificateGet = '/ehs/certificate/get',

}

/**
 * 获取资质证照
 */
export function queryCertificateInfo(params: CertificateQueryConditionDto , mode: ErrorMessageMode = 'modal') {
    return defHttp.post<CertificateListModel>(
        {
            url: Api.CertificateQuery,
            data: params
        },
        {
            errorMessageMode: mode
        },
    );
}

/**
 * 获取资质新增数据
 */
export function addCertificateInfo(params: CertificateDto , mode: ErrorMessageMode = 'modal') {
    return defHttp.post<string>(
        {
            url: Api.CertificateAdd,
            params
        },
        {
            errorMessageMode: mode
        },
    );
}

/**
 * 获取资质修改数据
 */
export function updateCertificateInfo(params: CertificateDto , mode: ErrorMessageMode = 'modal') {
    return defHttp.put<string>(
        {
            url:Api.CertificateUpdate,
            params
        },
        {
            errorMessageMode: mode
        }
    )
}

/**
 * 获取指定证照
 */
export function getCertificateInfo(id:string , mode: ErrorMessageMode = 'modal') {
    return defHttp.get<CertificateDto>(
        {
            url:Api.CertificateGet,
            params:{id:id}
        },
        {
            errorMessageMode: mode
        }
    )
}

/**
 * 获取资质删除数据
 */
export function deleteCertificateInfo(id:string , mode: ErrorMessageMode = 'modal') {
    return defHttp.delete<string>(
        {
            url:Api.CertificateDelete,
            params:{id}
        },
        {
            errorMessageMode: mode,
            joinParamsToUrl: true,
        }
    )
}




